package io.gitee.duxiuhuan.mailbox.outter;

import io.gitee.duxiuhuan.mailbox.service.inter.QueryTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class QueryTableUtils {
    
    @Autowired
    private QueryTable queryTable;
    
    //用table表名字符串穿惨
    public Boolean createTable(String tableName) {
        return queryTable.createTable(tableName);
    }
    
    public Boolean dropTable(String tableName) {
        return queryTable.dropTable(tableName);
    }
    
    public Boolean updateTable(String oldTableName, String newTableName) {
        return queryTable.updateTable(oldTableName, newTableName);
    }
    
    public List<String> selectTable(String tableName) {
        return queryTable.selectTable(tableName);
    }
    
    //用tableId穿惨，转换为表名，调用表名穿参的方法
    public Boolean createTable(Long tableId) {
        return this.createTable("table_" + tableId.toString());
    }
    
    public Boolean dropTable(Long tableId) {
        return this.dropTable("table_" + tableId.toString());
    }
    
    public Boolean updateTable(Long oldTableId, Long newTableId) {
        return this.updateTable("table_" + oldTableId.toString(), "table_" + newTableId.toString());
    }
    
    public Boolean updateTable(Long oldTableId, String newTableName) {
        return this.updateTable("table_" + oldTableId.toString(), newTableName);
    }
    
    public List<String> selectTable(Long tableId) {
        return this.selectTable("table_" + tableId.toString());
    }
}
